
public class Test15 {
    public static void main(String[] args) throws InterruptedException {
        Runnable target = () -> {
            for (int i = 0; i < 3; i++) {
                System.out.println(Thread.currentThread().getName()
                 + "：我还在工作！");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println(Thread.currentThread().getName() + "：我结束了！");
        };
        Thread t1 = new Thread(target,"李四");
        Thread t2 = new Thread(target,"王五");
        System.out.println("先让李四开始工作");
        t1.start();
        t1.join();
        System.out.println("李四工作结束了,开始让王五开始工作");
        t2.start();
        t2.join();
        System.out.println("王五工作结束了");
    }
}
